import {PatientsData} from '@/demo-data/types/patient';
import {Patient} from "@/demo-data/types/patient";

export const patientsData: PatientsData = {
  patients: [
    {
      patient_id: "PT2025001",
      name: "黎天剑",
      status: "随访中",
      gender: "男",
      age: 45,
      medical_record_number: "280339",
      phone: "13603002228",
      disease_records: [
        {
          date: "2025-01-05",
          description: "确诊为高尿酸血症，血尿酸值520 μmol/L"
        },
        {
          date: "2024-11-25",
          description: "左足部关节疼痛、红肿、活动受限"
        },
        {
          date: "2024-10-10",
          description: "血尿酸偏高，建议进一步检查"
        }
      ],
      imaging_results: [
        {
          type: "CT",
          date: "2025-01-05",
          result: "未发现出血"
        },
        {
          type: "肾脏B超",
          date: "2025-01-05",
          result: "未发现出血"
        }
      ],
      lab_results: {
        blood_uric_acid: {
          value: 520,
          unit: "μmol/L",
          date: "2024-12-10",
          reference_range: "150-420"
        },
        creatinine: {
          value: 78,
          unit: "μmol/L",
          date: "2024-12-10",
          reference_range: "44-133"
        }
      },
      follow_up_plan: {
        followup_type: ["中风险组", "科研组"],
        next_follow_up: "2025年1月10日上午10:00"
      },
      follow_up_records: [
        {
          date: "2024-12-10",
          status: "已完成",
          description: "首次随访，制定治疗方案"
        },
        {
          date: "2024-11-25",
          status: "已完成",
          description: "急性发作随访，调整用药"
        }
      ],
      "blood_uric_acid_trend": {
        "data": [
          {"time": "2024-10", "value": 418},
          {"time": "2024-11", "value": 528},
          {"time": "2024-12", "value": 460},
          {"time": "2025-01", "value": 518},
          {"time": "2025-02", "value": 468},
          {"time": "2025-03", "value": 428}
        ]
      },
    },
    {
      patient_id: "PT2025002",
      name: "纪建源",
      status: "随访中",
      gender: "男",
      age: 45,
      medical_record_number: "280343",
      phone: "13603002228",
      disease_records: [
        {
          date: "2024-12-15",
          description: "确诊为高尿酸血症，血尿酸值600 μmol/L"
        },
        {
          date: "2024-11-30",
          description: "右足部关节疼痛、红肿、活动受限"
        },
        {
          date: "2024-10-20",
          description: "血尿酸偏高，建议进一步检查"
        }
      ],
      imaging_results: [
        {
          type: "CT",
          date: "2025-01-10",
          result: "未发现出血"
        },
        {
          type: "肾脏B超",
          date: "2025-02-10",
          result: "未发现出血"
        }
      ],
      lab_results: {
        blood_uric_acid: {
          value: 600,
          unit: "μmol/L",
          date: "2023-12-15",
          reference_range: "150-420"
        },
        creatinine: {
          value: 95,
          unit: "μmol/L",
          date: "2023-12-15",
          reference_range: "44-133"
        }
      },
      follow_up_plan: {
        followup_type: ["低风险组", "科研组"],
        next_follow_up: "2024年1月15日上午9:00"
      },
      follow_up_records: [
        {
          date: "2024-12-15",
          status: "已完成",
          description: "首次随访，制定治疗方案"
        },
        {
          date: "2024-11-30",
          status: "已完成",
          description: "急性发作随访，调整用药"
        }
      ],
      "blood_uric_acid_trend": {
        "data": [
          {"time": "2024-10", "value": 418},
          {"time": "2024-11", "value": 528},
          {"time": "2024-12", "value": 460},
          {"time": "2025-01", "value": 518},
          {"time": "2025-02", "value": 468},
          {"time": "2025-03", "value": 428}
        ]
      }
    },
    {
      patient_id: "PT2025003",
      name: "徐雄",
      status: "随访中",
      gender: "男",
      age: 45,
      medical_record_number: "280343",
      phone: "18956961719",
      disease_records: [
        {
          date: "2024-12-20",
          description: "确诊为高尿酸血症，血尿酸值550 μmol/L"
        },
        {
          date: "2024-12-05",
          description: "左足部关节疼痛、红肿、活动受限"
        },
        {
          date: "2024-11-10",
          description: "血尿酸偏高，建议进一步检查"
        }
      ],
      imaging_results: [
        {
          type: "CT",
          date: "2025-01-15",
          result: "未发现出血"
        },
        {
          type: "肾脏B超",
          date: "2025-02-15",
          result: "未发现出血"
        }
      ],
      lab_results: {
        blood_uric_acid: {
          value: 550,
          unit: "μmol/L",
          date: "2024-12-20",
          reference_range: "150-420"
        },
        creatinine: {
          value: 88,
          unit: "μmol/L",
          date: "2024-12-20",
          reference_range: "44-133"
        }
      },
      follow_up_plan: {
        followup_type: ["低风险组", "科研组"],
        next_follow_up: "2024年1月20日上午10:30"
      },
      follow_up_records: [
        {
          date: "2024-12-20",
          status: "已完成",
          description: "首次随访，制定治疗方案"
        },
        {
          date: "2023-12-05",
          status: "已完成",
          description: "急性发作随访，调整用药"
        }
      ],
      "blood_uric_acid_trend": {
        "data": [
          {"time": "2024-10", "value": 418},
          {"time": "2024-11", "value": 528},
          {"time": "2024-12", "value": 460},
          {"time": "2025-01", "value": 518},
          {"time": "2025-02", "value": 468},
          {"time": "2025-03", "value": 428}
        ]
      }
    },
    {
      patient_id: "PT2025004",
      name: "涛林",
      status: "随访中",
      gender: "男",
      age: 45,
      medical_record_number: "280343",
      phone: "15265412541",
      disease_records: [
        {
          date: "2024-12-25",
          description: "确诊为高尿酸血症，血尿酸值580 μmol/L"
        },
        {
          date: "2024-12-10",
          description: "右足部关节疼痛、红肿、活动受限"
        },
        {
          date: "2024-11-15",
          description: "血尿酸偏高，建议进一步检查"
        }
      ],
      imaging_results: [
        {
          type: "CT",
          date: "2025-01-20",
          result: "未发现出血"
        },
        {
          type: "肾脏B超",
          date: "2025-02-20",
          result: "未发现出血"
        }
      ],
      lab_results: {
        blood_uric_acid: {
          value: 580,
          unit: "μmol/L",
          date: "2024-12-25",
          reference_range: "150-420"
        },
        creatinine: {
          value: 92,
          unit: "μmol/L",
          date: "2024-12-25",
          reference_range: "44-133"
        }
      },
      follow_up_plan: {
        followup_type: ["低风险组", "科研组"],
        next_follow_up: "2024年1月25日上午9:30"
      },
      follow_up_records: [
        {
          date: "2024-12-25",
          status: "已完成",
          description: "首次随访，制定治疗方案"
        },
        {
          date: "2024-12-10",
          status: "已完成",
          description: "急性发作随访，调整用药"
        }
      ],
      "blood_uric_acid_trend": {
        "data": [
          {"time": "2024-10", "value": 418},
          {"time": "2024-11", "value": 528},
          {"time": "2024-12", "value": 460},
          {"time": "2025-01", "value": 518},
          {"time": "2025-02", "value": 468},
          {"time": "2025-03", "value": 428}
        ]
      },
    }
    // 其他患者数据...
    // 注意：您提供的JSON中有重复的patient_id和部分数据需要修正
  ]
};

// 获取所有患者数据
export const getAllPatients = (): Patient[] => {
  return patientsData.patients;
};

// 根据ID获取单个患者数据
export const getPatientById = (id: string) => {
  return patientsData.patients.find(patient => patient.patient_id === id);
};

// 获取高风险患者
export const getHighRiskPatients = (): Patient[] => {
  return patientsData.patients.filter(patient =>
    patient.follow_up_plan.followup_type.includes("高风险组")
  );
};
